package com.xykj.enterprise.wechat.ext.service.customer;

import com.xykj.enterprise.wechat.bean.ext.BaseResp;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.AddContactWayVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.AddCorpTagVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.ExternalContactListVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.ExternalContactVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.GetContactWayVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.GetCorpTagListVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.GetExternalContactBatchVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.GetFollowUserListVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.GetUnassignedListVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.GroupChatListVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.GroupChatVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.TransferCustomerVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.TransferGroupChatVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.TransferResultVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.moment.GetMomentCommentsVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.moment.GetMomentCustomerListVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.moment.GetMomentListVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.moment.GetMomentSendResultVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.moment.GetMomentTaskVo;
import com.xykj.enterprise.wechat.ext.service.QYWXHttpCommUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
@Slf4j
public class ExternalContactServiceImpl implements ExternalContactService {

    @Override
    public GetFollowUserListVo getFollowUserList(String accessToken) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/get_follow_user_list", params, GetFollowUserListVo.class);

    }

    @Override
    public AddContactWayVo addContactWayMiniprogram(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/add_contact_way", params, AddContactWayVo.class);

    }

    @Override
    public AddContactWayVo addContactWayQrcode(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/add_contact_way", params, AddContactWayVo.class);

    }

    @Override
    public BaseResp deleteContactWay(String accessToken, String config_id) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("config_id", config_id);
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/del_contact_way", params, GetContactWayVo.class);

    }

    @Override
    public GetContactWayVo getContactWay(String accessToken, String config_id) {
        Map params = new HashMap();
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/get_contact_way", params, GetContactWayVo.class);
    }

    @Override
    public BaseResp updateContactWay(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/update_contact_way", params, BaseResp.class);
    }

    @Override
    public ExternalContactListVo externalContactList(String accessToken, String userid) {
        Map params = new HashMap();
        params.put("access_token", accessToken);
        params.put("userid", userid);
        return QYWXHttpCommUtil.get("externalcontact/list", params, ExternalContactListVo.class);

    }

    @Override
    public BaseResp externalContactRemark(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/remark", params, BaseResp.class);

    }

    @Override
    public ExternalContactVo getExternalContact(String accessToken, String external_userid) {
        Map params = new HashMap();
        params.put("access_token", accessToken);
        params.put("external_userid", external_userid);
        return QYWXHttpCommUtil.get("externalcontact/get", params, ExternalContactVo.class);

    }

    @Override
    public GetExternalContactBatchVo getExternalContactBatch(String accessToken, String userid, String cursor, Integer limit) {
        Map param = new HashMap();
        param.put("access_token", accessToken);
        param.put("userid", userid);
        param.put("cursor", cursor);
        param.put("limit", limit);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/batch/get_by_user", param, GetExternalContactBatchVo.class);

    }

    @Override
    public GetCorpTagListVo getCorpTagList(String accessToken, String[] tag_id, String[] group_id) {
        Map params = new HashMap();
        params.put("access_token", accessToken);
        params.put("tag_id", tag_id);
        params.put("group_id", group_id);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/get_corp_tag_list", params, GetCorpTagListVo.class);

    }

    @Override
    public AddCorpTagVo addCorpTag(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/add_corp_tag", params, AddCorpTagVo.class);

    }

    @Override
    public BaseResp editCorpTag(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/edit_corp_tag", params, BaseResp.class);

    }

    @Override
    public BaseResp deleteCorpTag(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/del_corp_tag", params, BaseResp.class);

    }

    @Override
    public BaseResp markCorpTag(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/mark_tag", params, BaseResp.class);

    }

    @Override
    public TransferCustomerVo transferCustomer(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/transfer_customer", params, TransferCustomerVo.class);

    }

    @Override
    public TransferResultVo transferResult(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/transfer_result", params, TransferResultVo.class);

    }

    @Override
    public GetUnassignedListVo getUnassignedList(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/get_unassigned_list", params, GetUnassignedListVo.class);

    }

    @Override
    public TransferCustomerVo transferResignedCustomer(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/resigned/transfer_customer", params, TransferCustomerVo.class);

    }

    @Override
    public TransferResultVo transferResignedResult(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/resigned/transfer_result", params, TransferResultVo.class);

    }

    @Override
    public TransferGroupChatVo transferGroupChat(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/groupchat/transfer", params, TransferGroupChatVo.class);

    }

    @Override
    public GroupChatListVo getGroupChatList(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/groupchat/list", params, GroupChatListVo.class);

    }

    @Override
    public GroupChatVo getGroupChat(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/groupchat/get", params, GroupChatVo.class);

    }

    @Override
    public GetMomentListVo getMomentList(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/get_moment_list", params, GetMomentListVo.class);

    }

    @Override
    public GetMomentTaskVo getMomentTask(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/get_moment_task", params, GetMomentTaskVo.class);

    }

    @Override
    public GetMomentCustomerListVo getMomentCustomerList(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/get_moment_customer_list", params, GetMomentCustomerListVo.class);

    }

    @Override
    public GetMomentSendResultVo getMomentSendResult(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/get_moment_send_result", params, GetMomentSendResultVo.class);
    }

    @Override
    public GetMomentCommentsVo getMomentComments(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("externalcontact/get_moment_comments", params, GetMomentCommentsVo.class);
    }

}
